package cn.com.zsw.gblog.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * @author Caizhf
 * @version 1.0
 * @date 下午2:31 2019/3/28
 * @description 分页Bean
 **/
@Data
public class PageRes<T> {

    @ApiModelProperty(example = "1563", value = "总记录数")
    private Long total;

    @ApiModelProperty(example = "1", value = "当前页码")
    private Long current;

    @ApiModelProperty(example = "10", value = "当前页返回记录数")
    private Long size;

    @ApiModelProperty(example = "", value = "详细内容列表")
    private List<T> records;

    public PageRes() {
    }

    public PageRes(IPage<T> page) {
        //将mybatisplus的分页Bean转化成自己的分页Bean
        this.records = page.getRecords();  //记录详情
        this.total = page.getTotal();
        this.current = page.getCurrent();
        this.size = page.getPages();
    }

    public PageRes(IPage<?> page, List<T> content) {
        //将mybatisplus的分页Bean转化成自己的分页Bean
        this.records = content;
        this.total = page.getTotal();
        this.current = page.getCurrent();
        this.size = page.getPages();
    }

}
